<UserControl x:Class="ConverterSystems.Workstation.Views.ControlPanelView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cs="http://schemas.convertersystems.com/workstation"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             xmlns:vm="clr-namespace:ConverterSystems.Workstation.ViewModels"
             Width="300"
             Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
             FontSize="14.667"
             d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
             d:DesignHeight="600"
             mc:Ignorable="d">
    <UserControl.Resources>
        <cs:IsEqualConverter x:Key="IsEqualConverter" />
        <system:Int16 x:Key="ModeOff">0</system:Int16>
        <system:Int16 x:Key="ModeHand">1</system:Int16>
        <system:Int16 x:Key="ModeAuto">2</system:Int16>
    </UserControl.Resources>
    <ScrollViewer>
        <Grid>
            <i:Interaction.Behaviors>
                <cs:DisableMouseWheelAndArrowKeysBehavior />
            </i:Interaction.Behaviors>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="96" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0"
                       Grid.ColumnSpan="2"
                       FontSize="26.667"
                       Text="{Binding Source={Localization:Translate Word=Robot 1}}" />
            <TextBlock Grid.Row="2"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Mode}}" />
            <ComboBox Grid.Row="2"
                      Grid.Column="1"
                      Margin="0,2"
                      HorizontalAlignment="Stretch"
                      SelectedIndex="{Binding Robot1Mode}">
                <ComboBoxItem Content="{Binding Source={Localization:Translate Word=Off}}" />
                <ComboBoxItem Content="{Binding Source={Localization:Translate Word=Hand}}" />
                <ComboBoxItem Content="{Binding Source={Localization:Translate Word=Auto}}" />
            </ComboBox>

            <!--  controls within this grid are enabled only if Robot1Mode is Hand  -->
            <Grid Grid.Row="3"
                  Grid.ColumnSpan="3"
                  IsEnabled="{Binding Robot1Mode,
                                      ConverterParameter={StaticResource ModeHand},
                                      Converter={StaticResource IsEqualConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="96" />
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           Text="{Binding Source={Localization:Translate Word=Axis 1, °}}" />
                <Slider Grid.Row="0"
                        Grid.Column="1"
                        Margin="0,2"
                        AutoToolTipPlacement="TopLeft"
                        IsSelectionRangeEnabled="True"
                        Maximum="180"
                        Minimum="-180"
                        SelectionEnd="{Binding Robot1Axis1}"
                        SelectionStart="{Binding Robot1Axis1}"
                        TickFrequency="30"
                        TickPlacement="TopLeft"
                        Value="{Binding Robot1Axis1}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           Text="{Binding Source={Localization:Translate Word=Axis 2, °}}" />
                <Slider Grid.Row="1"
                        Grid.Column="1"
                        Margin="0,2"
                        AutoToolTipPlacement="TopLeft"
                        IsSelectionRangeEnabled="True"
                        LargeChange="5"
                        Maximum="45"
                        Minimum="-45"
                        SelectionEnd="{Binding Robot1Axis2}"
                        SelectionStart="{Binding Robot1Axis2}"
                        TickFrequency="15"
                        TickPlacement="TopLeft"
                        Value="{Binding Robot1Axis2}" />
                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           Text="{Binding Source={Localization:Translate Word=Axis 3, °}}" />
                <Slider Grid.Row="2"
                        Grid.Column="1"
                        Margin="0,2"
                        AutoToolTipPlacement="TopLeft"
                        IsSelectionRangeEnabled="True"
                        Maximum="45"
                        Minimum="-45"
                        SelectionEnd="{Binding Robot1Axis3}"
                        SelectionStart="{Binding Robot1Axis3}"
                        TickFrequency="15"
                        TickPlacement="TopLeft"
                        Value="{Binding Robot1Axis3}" />
                <TextBlock Grid.Row="3"
                           Grid.Column="0"
                           Text="{Binding Source={Localization:Translate Word=Axis 4, °}}" />
                <Slider Grid.Row="3"
                        Grid.Column="1"
                        Margin="0,2"
                        AutoToolTipPlacement="TopLeft"
                        IsSelectionRangeEnabled="True"
                        LargeChange="10"
                        Maximum="180"
                        Minimum="-180"
                        SelectionEnd="{Binding Robot1Axis4,
                                               Mode=OneWay}"
                        SelectionStart="{Binding Robot1Axis4,
                                                 Mode=OneWay}"
                        SmallChange="5"
                        TickFrequency="30"
                        TickPlacement="TopLeft"
                        Value="{Binding Robot1Axis4}" />
            </Grid>

            <TextBlock Grid.Row="4"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Laser}}" />
            <metro:ToggleSwitch Grid.Row="4"
                                Grid.Column="1"
                                Margin="0,2"
                                IsChecked="{Binding Robot1Laser}" />
            <TextBlock Grid.Row="5"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Speed}}" />
            <ListBox Grid.Row="5"
                     Grid.Column="1"
                     SelectedIndex="{Binding Robot1Speed}"
                     Style="{DynamicResource RadioButtonList}">
                <ListBoxItem Content="{Binding Source={Localization:Translate Word=Slow}}" />
                <ListBoxItem Content="{Binding Source={Localization:Translate Word=Medium}}" />
                <ListBoxItem Content="{Binding Source={Localization:Translate Word=Fast}}" />
                <ListBoxItem Content="{Binding Source={Localization:Translate Word=Turbo}}" />
            </ListBox>
            <TextBlock Grid.Row="6"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Command}}" />
            <StackPanel Grid.Row="6"
                        Grid.Column="1"
                        Orientation="Horizontal">
                <Button x:Name="StopButton"
                        Command="{Binding Robot1ModeCommand,
                                          Mode=OneWay}"
                        CommandParameter="{StaticResource ModeOff}"
                        Content="{Binding Source={Localization:Translate Word=Stop}}" />
                <Button x:Name="StartButton"
                        Command="{Binding Robot1ModeCommand,
                                          Mode=OneWay}"
                        CommandParameter="{StaticResource ModeAuto}"
                        Content="{Binding Source={Localization:Translate Word=Start}}" />
            </StackPanel>
            <TextBlock Grid.Row="7"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Axis 1, °}}" />
            <TextBlock Grid.Row="7"
                       Grid.Column="1"
                       HorizontalAlignment="Right"
                       Text="{Binding MaxValue,
                                      ElementName=Trend1,
                                      StringFormat=F1}" />
            <cs:Trendline x:Name="Trend1"
                          Grid.Row="8"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Height="100"
                          Background="{DynamicResource GrayBrush10}"
                          ItemsSource="{Binding Robot1Axis1Queue}"
                          Stroke="{DynamicResource HighlightBrush}" />
            <TextBlock Grid.Row="9"
                       Grid.Column="0"
                       Text="{Binding TimeSpan.TotalSeconds,
                                      ElementName=Trend1,
                                      Mode=OneWay,
                                      StringFormat=\{0:F0\} s}" />
            <TextBlock Grid.Row="9"
                       Grid.Column="1"
                       HorizontalAlignment="Right"
                       Text="{Binding MinValue,
                                      ElementName=Trend1,
                                      StringFormat=F1}" />
            <TextBlock Grid.Row="10"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Input A}}" />
            <TextBox x:Name="InputA"
                     Grid.Row="10"
                     Grid.Column="1"
                     Margin="0,2"
                     Text="{Binding InputA}" />
            <TextBlock Grid.Row="11"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Input B}}" />
            <TextBox x:Name="InputB"
                     Grid.Row="11"
                     Grid.Column="1"
                     Margin="0,2"
                     Text="{Binding InputB}" />
            <TextBlock Grid.Row="12"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Method}}" />
            <StackPanel Grid.Row="12"
                        Grid.Column="1"
                        Orientation="Horizontal">
                <Button x:Name="MultiplyButton"
                        Command="{Binding Robot1MultiplyCommand}"
                        Content="{Binding Source={Localization:Translate Word=Multiply}}"
                        IsDefault="True" />
                <Button x:Name="ClearButton"
                        Command="{Binding ClearCommand}"
                        Content="{Binding Source={Localization:Translate Word=Clear}}" />
            </StackPanel>
            <TextBlock Grid.Row="13"
                       Grid.Column="0"
                       Text="{Binding Source={Localization:Translate Word=Result}}" />
            <TextBox x:Name="Result"
                     Grid.Row="13"
                     Grid.Column="1"
                     Margin="0,2"
                     Text="{Binding Result}" />
        </Grid>
    </ScrollViewer>
</UserControl>
